"use strict";
import * as React from 'react';
import { autoSize, commonStyles } from "../assets/styles/common";
import MyText from "./MyText";
const { Image, View } = require('react-native');
class Avatar extends React.Component {
    renderContent() {
        const { content } = this.props;
        if (content) {
            if (typeof content === 'string') {
                return <MyText fontSize={12} color='#999'>{content}</MyText>;
            }
            else if (Array.isArray(content)) {
                return content;
            }
            else {
                return content;
            }
        }
        return null;
    }
    render() {
        const { size, circle, borderWidth, borderColor, source } = this.props;
        if (source) {
            return (<Image {...this.props} style={[{
                    width: size,
                    height: size,
                    borderRadius: circle ? size / 2 : 0,
                    borderWidth,
                    borderColor
                }, this.props.style]}/>);
        }
        else {
            return (<View style={[{
                    width: size,
                    height: size,
                    borderRadius: circle ? size / 2 : 0,
                    borderWidth,
                    borderColor,
                    backgroundColor: '#f4f4f4'
                }, commonStyles.centerVH, this.props.style]}>
                    {this.renderContent()}
                </View>);
        }
    }
}
Avatar.defaultProps = {
    size: autoSize(40),
    circle: true,
    borderWidth: 0,
    borderColor: 'transparent',
    content: null,
};
export default Avatar;
